package zeebe.awaitWorkflowResult;

import io.vertx.core.json.JsonObject;
import io.zeebe.client.ZeebeClient;
import io.zeebe.client.api.response.WorkflowInstanceResult;

public class AwaitWorkflowResultStart {
    public static void main(String[] args) {
        ZeebeClient client=ZeebeClient.newClientBuilder()
                .brokerContactPoint("localhost:26500")
                .usePlaintext()
                .build();

        System.out.println("启动工作流");
        String processId = "awaitWorkflowResult";

        JsonObject data=new JsonObject()
                .put("a",1)
                .put("b",2);

        WorkflowInstanceResult workflowInstanceResult=client.newCreateInstanceCommand()
                .bpmnProcessId(processId)
                .latestVersion()
                .variables(data.encode())
                .withResult()
                .send()
                .join();

        System.out.println("流程结果："+workflowInstanceResult.getVariables());
    }
}
